var app=angular.module('myApp', []).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
      when('/', {templateUrl: 'report_ageing.html', controller: ListExpMstCtrl}).      
      when('/cancel/', {templateUrl: 'report_ageing.html', controller: ListExpMstCtrl}). 
      otherwise({redirectTo: '/'});
}]);


function ListExpMstCtrl($scope, $http,$window,$location,$filter)
 {
 
    $scope.currentPage = 0;
    $scope.pageSize = 25;
	$scope.Math = window.Math;
	$scope.ed = false;
	$scope.soc_arr = [];
	$scope.yr_arr = [];

    $http.get('report_ageing_data.php').success(function(data) {	
		$scope.mismast = data;
		for(var i=0; i<data.length;i++){
			$scope.soc_arr[i] = data[i].sname;		
			$scope.yr_arr[i] = data[i].year;		
		}
		$scope.soc_arr = jQuery.unique( $scope.soc_arr );		
		$scope.soc_arr.sort();
		
		$scope.yr_arr = jQuery.unique( $scope.yr_arr );
		$scope.yr_arr.sort();
		$scope.yr_arr.reverse();
		$scope.search1 = $scope.yr_arr[0];
    });
	  
	  //Function to Clear 
        $scope.cancel= function()
		{
			$scope.activePath = null;
			$scope.activePath = $location.path('report_ageing.php');
		};
      
 }
    
        //Custom Filter Function to sort the record.
    app.filter('startingFrom', function() 
    {
            return function(input, start) 
            {
                start = +start; //parse to int
                return input.slice(start);
            };
    });
	
        